<?php
class sfWebAjaxResponse extends sfWebResponse {
  protected $jsCall;
  protected $transferErrorFieldNames = array();
  protected $transferErrorToFeedbackFieldNames = array();
  protected $fieldIdPrefix;
  
  
  public function setTransferErrorFieldNames($ar) {
      $this->transferErrorFieldNames = $ar;
  }

  public function getTransferErrorFieldNames() {
      return $this->transferErrorFieldNames;
  }

  public function setTransferErrorToFeedbackFieldNames($ar) {
      $this->transferErrorToFeedbackFieldNames = $ar;
  }
  
  public function getTransferErrorToFeedbackFieldNames() {
      return $this->transferErrorToFeedbackFieldNames;
  }
  
  public function setFieldIdPrefix($st) {
      $this->fieldIdPrefix = $st;
  }
  
  public function getFieldIdPrefix() {
      return $this->fieldIdPrefix;
  }
  
  /**
   * Send content for the current web response.
   *
   */
  public function sendContent()
  {
    if (!$this->headerOnly)
    {
      if($this->jsCall) {
        echo $this->jsCall->toJson();     
      }
      else {
        parent::sendContent();
      }
    }
  }
  
  public function setJsCall(JsCall &$jsCall) {
      $this->jsCall = $jsCall;
  }
  
  public function & getJsCallReference()  {
      if(!($this->jsCall instanceOf JsCall)) {
          $this->jsCall = JsCall::build();
      }
      return $this->jsCall;
  }

  /**
   * Sends the HTTP headers and the content.
   */
  public function send()
  {
    $this->sendHttpHeaders();
    $this->sendContent();
  }
  
}